package com.huadao.cart_ccs.common.threadControl;

public class ThreadPoolProxyFactory {
    static ThreadPoolProxy mNormalThreadPoolProxy;
    static ThreadPoolProxy mSerialPortThreadPoolProxy;
    static ThreadPoolProxy mIOThreadPoolProxy;
    static ThreadPoolProxy mSingleThreadPoolProxy;

    /**
     * 得到普通线程池代理对象mNormalThreadPoolProxy
     */
    public static ThreadPoolProxy getNormalThreadPoolProxy() {
        if (mNormalThreadPoolProxy == null) {
            synchronized (ThreadPoolProxyFactory.class) {
                if (mNormalThreadPoolProxy == null) {
                    mNormalThreadPoolProxy = new ThreadPoolProxy(3, 10);
                }
            }
        }
        return mNormalThreadPoolProxy;
    }

    /**
     * 得到串口通讯线程池代理对象mSerialPortThreadPoolProxy
     */
    public static ThreadPoolProxy getSerialPortThreadPoolProxy() {
        if (mSerialPortThreadPoolProxy == null) {
            synchronized (ThreadPoolProxyFactory.class) {
                if (mSerialPortThreadPoolProxy == null) {
                    mSerialPortThreadPoolProxy = new ThreadPoolProxy(1, 10);
                }
            }
        }
        return mSerialPortThreadPoolProxy;
    }

    /**
     * 得到IO线程池代理对象mIOThreadPoolProxy
     */
    public static ThreadPoolProxy getIOThreadPoolProxy() {
        if (mIOThreadPoolProxy == null) {
            synchronized (ThreadPoolProxyFactory.class) {
                if (mIOThreadPoolProxy == null) {
                    mIOThreadPoolProxy = new ThreadPoolProxy(3, 3);
                }
            }
        }
        return mIOThreadPoolProxy;
    }

    /**
     * mSingleThreadPoolProxy
     */
    public static ThreadPoolProxy getSingleThreadPoolProxy(){
        if(mSingleThreadPoolProxy==null){
            synchronized (ThreadPoolProxyFactory.class) {
                if (mSingleThreadPoolProxy == null) {
                    mSingleThreadPoolProxy = new ThreadPoolProxy(1, 1);
                }
            }
        }
        return mSingleThreadPoolProxy;
    }
}